package com.shushan.mixedexam.bean;


import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * @ClassName: MutiExerciseOptionBean
 * @Desciption: //多种练习选项数据bean
 * @author: zhangshihao
 * @date: 2018-07-31
 */
public class MutiExerciseOptionBean extends NetBaseBean {

    public int id;
    public int exercises_id;
    public String option_content;
    public String option_imgs;
    public String image_size;
    public String content_type;
    public int option_result;

    private int answerIndex = -1;

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }
        id = jsonObject.optInt("id",0);
        exercises_id = jsonObject.optInt("exercises_id",0);
        option_imgs = jsonObject.optString("option_imgs","");
        image_size = jsonObject.optString("image_size","");
        content_type = jsonObject.optString("content_type","");
        option_result = jsonObject.optInt("option_result", 0);

        JSONArray optContentArr = jsonObject.optJSONArray("option_content");
        if(optContentArr != null && optContentArr.length() > 0){
            StringBuffer sb = new StringBuffer();
            for(int i=0;i<optContentArr.length();i++) {
                sb.append(optContentArr.optString(i, ""));
            }
            option_content = sb.toString();
        }
    }

    public int getAnswerIndex() {
        return answerIndex;
    }

    public void setAnswerIndex(int answerIndex) {
        this.answerIndex = answerIndex;
    }

}
